package com.dms.dao.impl;

import java.util.List;

import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.dms.dao.BuildingDao;
import com.dms.model.Building;

@Repository
public class BuildingDaoImpl extends BaseDaoImpl implements BuildingDao {

	@Override
	public Building getBuilding(String hql) {	
		return (Building) getSession().createQuery(hql).uniqueResult();
	}

	@Override
	public void updateBuilding(Building building) {
		Session session=this.getSession();
		session.merge(building);
		session.flush();
		
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Building> getBuildings(String hql) {
		return getSession().createQuery(hql).list();
	}

	@Override
	public void save(Building building) {
		this.getSession().save(building);
		
	}

	@Override
	public void delete(int id) {
		Session session=this.getSession();
		session.delete(session.get(Building.class, id));
		session.flush();
	}

	

}
